package cn.guangboyuan.dynamindatasource.service.impl;

import cn.guangboyuan.dynamindatasource.config.datasource.DataSourceNames;
import cn.guangboyuan.dynamindatasource.config.datasource.DynaminDataSource;
import cn.guangboyuan.dynamindatasource.entity.SysUser;
import cn.guangboyuan.dynamindatasource.mapper.SysUserMapper;
import cn.guangboyuan.dynamindatasource.service.SysUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * 系统用户 服务实现类
 *
 * @author RedAnts
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    @Override
    @DynaminDataSource(names = {DataSourceNames.STR_MASTER})
    public Integer insertSysUser(SysUser sysUser) {
        return baseMapper.insert(sysUser);
    }

    @DynaminDataSource(names = {DataSourceNames.STR_SLAVE1, DataSourceNames.STR_SLAVE2})
    @Override
    public SysUser findUserById(long id) {
        return this.baseMapper.selectById(id);
    }

}
